Creating layers

Layers in OpenCPN are basically gpx-files. Gpx-files can be used to describe waypoints, tracks and routes.
On this page we will explain the basics of gpx-files so that you might even create them yourselves.
Gpx-files are “human-readable” textfiles containing information in a structured way and are “easily” created by tools or programs.

Tracks and routes

In OpenCPN, tracks describe where you were with your ship and OpenCPN can create them automatically for you when you are sailing.

From tracks you could create and save routes for making the same trip again sometime.
You can also create or manipulate routes with external (planning)tools.

GPX File Header information

Every gpx-file has headerinformation, describing the gpx-file, what schema(s) are used and you can also put some information in it describing yourself ;-)
It's quite standard and is mandatory. When developing your own layers you can create a standard-header with the necessary information and “reuse” it for other layers you may produce by changing just a few things in it.

Waypoints (or Points Of Interest)

Overview of Waypoints

First we will focus on gpx-files containing waypoints.
Gpx-files with waypoints can contain information about sailing-related information like position of wrecks, buoys, bridges, locks and mooring spots but could also contain information about less “sailing related” information.

In OpenCPN there are different data “connected” to waypoints.

Coordinates

Every waypoint has coordinates connected to it, to place them on the map.
The coordinates of the waypoint (laitude and logitude) are expressed in decimal degrees using the WGS 84 datum.


The WGS 84 datum is the same coordinate-system as used by Google maps for example.
When double clicking somewhere on the map in Google maps, you will find that Google “zooms in” to the point you double-clicked on by changing the url.
For example double-clicking on the small island we like to moor on, during the sailing season, the url changes to:
https://www.google.com/maps/@53.0304726,5.7715901**,640m/data=!3m1!1e3?hl=en

with within the url the latitude and longitude comma-seperated (I made them bold in the example).
The latitude in this example is 53.0304726 and the longitude is 5.7715901.

Symbol

At the spot determined by the forementioned coordinates a symbol is placed on the map in OpenCPN.
You can determine the symbol displayed on the map by it's name.
For each symbol used, there has to be a picturefile available in the UserIcons-folder located under the folder where OpenCPN keeps its configuration-file.
OpenCPN will load this picture on the map. For each different symbol one picture-file has to be available.
If you create, for example, a gpx-file with all bunkerstations for getting fuel and/or water, you only have to create one picturefile with a symbol you want to use for bunkerstaions.
If there's no symbol with the correct name you put in the gpx-file in the UserIcons-folder, OpenCPN will use a circle with a dot in the middle.
So when you distribute your gpx-file to potential users, please distribute the “to be used” picturefiles WITH the layers.
When doing so, please think of a “unique” name in doing so, as more layer-producers may have the same idea ;-)
For example, layers produced by the Openwaterkaart-project use symbols with names starting with ow_ so please use another unique-making combination for your own to prevent that “your” symbol will be overwritten by (or overwrites) others when using layers of different suppliers.

Text-information displayed next to the symbol

You can have OpenCPN display a text beside the Symbol.
Using the same example of bunkerstations, you could have the name of the bunkerstation and/or the phonenumber to dial in that text.
For the users of that gpx-file, the neccesary information could be visible directly on the map they look at.

It's possible to let OpenCPN display the information in different lines. When you want to use more then one line beside the symbol (for example having the name in the first line and the phonenumber in the second) you can seperate the two lines in the gpx-file by placing between the lines.

In OpenCPN you can select the text-information to be visible or not by checking the appropriate box beside the layers.
This way, the user can select the appropriate information to be visible on their map.

Description of the waypoint

Beside the text displayed on the map, you can also “attach” a description to a waypoint. This text is NOT displayed on the map directly but you can make it visible as a user by checking the propterties of the waypoint. In this description you could place some additional information. In the example of the bunkerstation, you could put some text like what “stuff” could be available at the bunkerstation. Like water, fuel (what sorts) or both or….. well whatever additional information you can think of being usefull but that not has to be diplayed on the map.

Symbol

At the spot determined by the forementioned coordinates a symbol is placed on the map in OpenCPN.
You can determine the symbol displayed on the map by it's name.
For each symbol used, there has to be a picturefile available in the UserIcons-folder located under the folder where OpenCPN keeps its configuration-file.
OpenCPN will load this picture on the map. For each different symbol one picture-file has to be available.
If you create, for example, a gpx-file with all bunkerstations for getting fuel and/or water, you only have to create one picturefile with a symbol you want to use for bunkerstaions.
If there's no symbol with the correct name you put in the gpx-file in the UserIcons-folder, OpenCPN will use a circle with a dot in the middle.
So when you distribute your gpx-file to potential users, please distribute the “to be used” picturefiles WITH the layers.
When doing so, please think of a “unique” name in doing so, as more layer-producers may have the same idea ;-)
For example, layers produced by the Openwaterkaart-project use symbols with names starting with ow_ so please use another unique-making combination for your own to prevent that “your” symbol will be overwritten by (or overwrites) others when using layers of different suppliers.

Text-information displayed next to the symbol

You can have OpenCPN display a text beside the Symbol.
Using the same example of bunkerstations, you could have the name of the bunkerstation and/or the phonenumber to dial in that text.
For the users of that gpx-file, the neccesary information could be visible directly on the map they look at.

It's possible to let OpenCPN display the information in different lines. When you want to use more then one line beside the symbol (for example having the name in the first line and the phonenumber in the second) you can seperate the two lines in the gpx-file by placing between the lines.

In OpenCPN you can select the text-information to be visible or not by checking the appropriate box beside the layers.
This way, the user can select the appropriate information to be visible on their map.

Description of the waypoint

Beside the text displayed on the map, you can also “attach” a description to a waypoint. This text is NOT displayed on the map directly but you can make it visible as a user by checking the properties of the waypoint. In this description you could place some additional information. In the example of the bunkerstation, you could put some text like what “stuff” could be available at the bunkerstation. Like water, fuel (what sorts) or both or….. well whatever additional information you can think of being usefull but that not has to be diplayed on the map.

Optional extensions

There is a way to “attach” some extra functionality to the waypoints. The needed “settings” for those are OpenCPN-specific (I think) and are added to the waypoints in the form of extensions. The extensions are “enclosed” by the <extensions>-tag.

Between that tag I found two useful extensions for addition to layers that you can create yourself:

waypoint_range_rings

The notation in the gpx-file is as follows:

 <opencpn:waypoint_range_rings visible="true" number="2" step="1" units="1" colour="#FFFFFF" />

With this extension you can put coloured circles around the specific waypoint to make it more visible compared to other waypoints.
With the visible=“true” part you can switch “on” this extension.
With number=“2” you create 2 circles around the waypoint with the color identified with the code #FFFFFF in colour=“#FFFFFF”.
I have still to determine what the units=“1” does.

scale_min_max

The notation in the gpx-file is as follows:

<opencpn:scale_min_max UseScale="true" ScaleMin="100000" ScaleMax="0" />

With this extension

With UseScale=“true” you can switch “on” this extension.

With this extension you can “dynamically” show or hide waypoints.
This example shows the object upto scale 1:100.000 (shown in the lower right corner of OpenCPN).
Above a scale of 1:100.000, set by ScaleMin=“100000” the waypoint is suppressed and thus not visible on the map.
Apparently only ScaleMin in this extension is used by OpenCPN as the “upper” scale-limit for visibility of the waypoint.

Example

Please not that this is somewhat “fake” data.
There actually IS a bunkerstation with the specified name in the example waypoint at the coordinates mentioned in the example but the phonenumber is really fake ;-)

<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>\\
<gpx\\
version="1.1"\\
creator="Klaus Spithost - klaus@openwaterkaart.nl"\\
xmlns:xsi="http:www.w3.org/2001/XMLSchema-instance"\\
xmlns="http:www.topografix.com/GPX/1/1"\\
xsi:schemaLocation="http:www.topografix.com/GPX/1/1 [[http://www.topografix.com/GPX/1/1/gpx.xsd|http://www.topografix.com/GPX/1/1/gpx.xsd"]]>\\
<metadata>\\
<name>NL Bunkerstations.gpx</name>\\
<time>2020-05-01T01:28:44 02:00</time>\\
<keywords>Bunkerstations Nederland</keywords>\\
</metadata>\\
<wpt lat="53.1621536" lon="5.9319974">\\
<name>Pier Pander (tel: 31-1234567890)</name>\\
<desc>Bunkerstation Pier Pander\\
Different kinds of fuel\\
</desc>\\
<sym>ow_bunker</sym>\\
<extensions>\\
<opencpn:waypoint_range_rings visible="true" number="2" step="1" units="2" colour="#FFFFFF" />\\
<opencpn:scale_min_max UseScale="true" ScaleMin="100000" ScaleMax="0" />\\
</extensions>\\
</wpt>\\
</gpx>

In this example you can “detect” the different parts of information described earlier. The waypoint described, is “enclosed” by the so called <wpt>-tag and the closing </wpt>-tag.
Within a gpx-file you can have an infinite number of waypoints with the same structure as described.
So after the closing </wpt>-tag, you can have another <wpt>-tag with the information of the next bunkerstation….
When you want more reading information about gpx-files, please Google :-)
I only describe the bare essentials here to produce your own layers.

The coordinates of the waypoint:
<wpt lat=“53.1621536” lon=“5.9319974”>

The symbol used for this waypoint:
<sym>ow_bunker</sym>
OpenCPN will look for a file with the name ow_bunker.png or ow_bunker.xpm (bitmap imageformat) to place at the coordinates.

The text displayed beside the waypoint:
<name>Pier Pander (tel: 31-1234567890)</name>
As described the text will consist of two lines with Pier pander in the first line and the phonenumber (tel: 31-1234567890) in the second.

The description of the waypoint:
<desc>Bunkerstation Pier Pander
Different kinds of fuel and water
</desc>

Usage

The gpx-files are to be places in the Layers-folder that can be created as a sub-folder of the folder containing the configuration-information of OpenCPN.
When placed in this specific folder, the layer is persistant (does not have to be imported in OpenCPN).
The name of the layer is determined from the filename of the gpx-file.
So if you were to save the example above to a layer and call it “bunker stations Nederland.gpx” it would present itself in OpenCPN as a layer with the name bunker stations Nederland.